package com.songlanyun.modules.config.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.common.utils.R;
import com.songlanyun.common.validator.ValidatorUtils;
import com.songlanyun.common.validator.group.AddGroup;
import com.songlanyun.common.validator.group.UpdateGroup;
import com.songlanyun.modules.config.model.PointGradeConfigDTO;
import com.songlanyun.modules.config.service.PointGradeConfigService;
import com.songlanyun.modules.user.controller.AbstractController;

/**
 * 积分配置-等级配置
 *
 * @author lijiahe
 * @email
 * @date 2022-09-21 14:58:22
 */
@RestController
@RequestMapping("config/point_grade_config")
public class PointGradeConfigController extends AbstractController {
    @Autowired
    private PointGradeConfigService pointGradeConfigService;

    /**
     * 信息
     */
    @GetMapping("/info")
    // @RequiresPermissions("config:point_grade_config:info")
    public R info() {
        return R.ok().put("data", pointGradeConfigService.info());
    }

    /**
     * 保存和修改
     */
    @PostMapping("/saveOrUpdate")
    // @RequiresPermissions("config:point_grade_config:saveOrUpdate")
    public R saveOrUpdate(@RequestBody PointGradeConfigDTO dto) {
        verifyAdmin();
        ValidatorUtils.validateEntity(dto, AddGroup.class, UpdateGroup.class);
        pointGradeConfigService.saveOrUpdatePointGrade(dto);
        return R.ok();
    }

}
